import { createApp } from 'vue'
import ElementPlus from 'element-plus'
import {createPinia} from "pinia";
import 'element-plus/dist/index.css'
import zhCn from 'element-plus/lib/locale/lang/zh-cn'
import App from './App.vue'
import router from "./router/routers";
import piniaPluginPersistedstate from 'pinia-plugin-persistedstate'
import * as ElementPlusIconsVue from '@element-plus/icons-vue'

import './assets/css/public.css'
import './assets/iconfont/iconfont.css'
import './assets/css/themes.css'

import './utils/message'
import './router/index'
import './utils/common'

const isDarkMode = localStorage.getItem('isDarkMode') !== 'false';
document.documentElement.setAttribute('data-theme', isDarkMode ? 'light' : 'dark');

const pinia = createPinia()
pinia.use(piniaPluginPersistedstate)

const app = createApp(App)

for (const [key, component] of Object.entries(ElementPlusIconsVue)) {
    app.component(key, component)
}

app.use(pinia)
app.use(ElementPlus, {locale: zhCn, size: 'default'}) // 额外设置ElementPlus所有组件默认大小，size可选 'large'| 'default'| 'small'
app.use(router)

app.mount('#app')
